import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
driver.maximize_window()

driver.find_element(By.LINK_TEXT, '新闻').click()
time.sleep(5)
print(driver.current_window_handle)
print(driver.window_handles)
driver.switch_to.window(driver.window_handles[1])
driver.close()
time.sleep(5)
driver.quit()
